using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using THSLib;
using THSERP.BusinessEntities;
namespace THSERP.BaseProvider
{
    public partial class guiObjectHistory : THSERPScreen
    {
        public guiObjectHistory()
        {
            InitializeComponent();
        }

        public guiObjectHistory(String strObjectName,String ObjectNo)
        {
            InitializeComponent();

            InitObjectHistoryGridControl(strObjectName, ObjectNo);
        }

        private void InitObjectHistoryGridControl(String strObjectName,String ObjectNo)
        {
            //String strObjectNumber = ObjectNo.ToString();
            GEObjectHistoryController objGEObjectHistoryController = new GEObjectHistoryController();            
            DataSet dsObjectHistory = objGEObjectHistoryController.GetGEObjectHistoryByObjectNumber(ObjectNo.ToString());
            
            if (dsObjectHistory != null)
            {
                if (dsObjectHistory.Tables.Count > 0)
                {
                    fld_dgcObjectHistory.DataSource = dsObjectHistory;
                    fld_dgcObjectHistory.DataMember = dsObjectHistory.Tables[0].TableName;
               }
            }
        }
            

        private void fld_btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

       
        private void fld_dgvObjectHistory_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                
                int rowHandle = fld_dgvObjectHistory.FocusedRowHandle;
                if (rowHandle >= 0)
                {
                    String iObjectNumber = fld_dgvObjectHistory.GetRowCellValue(rowHandle, colGEObjectHistoryObjectNumber).ToString();
                    guiObjectHistoryDetails _guiObjectHistoryDetails = new guiObjectHistoryDetails(rowHandle, iObjectNumber);
                    _guiObjectHistoryDetails.ShowDialog();
                }
            }catch(Exception ex)
            {
            }
        }

        private void fld_btnDetails_Click(object sender, EventArgs e)
        {
            
            int rowHandle = fld_dgvObjectHistory.FocusedRowHandle;
            if (rowHandle >= 0)
            {
                String ObjectNumber = fld_dgvObjectHistory.GetRowCellValue(rowHandle, colGEObjectHistoryObjectNumber).ToString();
                guiObjectHistoryDetails _guiObjectHistoryDetails = new guiObjectHistoryDetails(rowHandle, ObjectNumber);
                _guiObjectHistoryDetails.ShowDialog();
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}